<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <title>houselai-admin</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/favicon.ico"/>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="/static/css/admin/bootstrap.min14ed.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/font-awesome.min93e3.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/dataTables/dataTables.bootstrap.css">
    <link rel="stylesheet" type="text/css" href="/static/css/admin/animate.min.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/admin/style.min862f.css"/>
    <link href="/static/css/admin/admincommon.css?v=20180820" rel='stylesheet' type='text/css'/>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>图片列表</h5>
                    <if condition="check_auth('admin/About/add')">
                        <button id="toggle_modal" class="btn btn-primary btn-circle" type="button"
                                style="margin-bottom:0px;margin-left:10px;position:relative;top:-5px;" title="添加图片">
                            <i class="fa fa-edit"></i>+
                        </button>
                    </if>
                    <div class="ibox-tools">
                        <a href="javascript:location.replace(location.href);" class="btn btn-primary btn-circle"
                           type="button" style="margin-bottom:0px;margin-right:10px;position:relative;top:-5px;"
                           title="刷新">
                            <i class="fa fa-refresh"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <table id="mytable" class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>启动图</th>
                            <th>外链地址</th>
                            <th>状态</th>
                            <th>排序</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <volist name="data" id="vo">
                            <tr class="gradeX" id="about-{$vo['id']}">
                                <td>{$vo['id']}</td>
                                <td><img src="{$vo['img_url']}" width="100" height="100"/></td>
                                <td>{$vo['outer_url']}</td>
                                <td>{$vo['statusName']}</td>
                                <td>{$vo['sort']}</td>
                                <td class="center" align="center">
                                    <div class="btn-group">
                                        <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle"
                                                aria-expanded="false">操作 <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu">
                                            <if condition="check_auth('admin/Hpage/updateStatus')">
                                                <li><a href="javascript:;" data-id="{$vo['id']}" data-status="{$vo['status']}"
                                                       class="font-bold edit-about">更新状态</a>
                                                </li>
                                            </if>
                                            <if condition="check_auth('admin/Hpage/update')">
                                                <li><a href="javascript:;" data-id="{$vo['id']}"
                                                       class="font-bold edit-hpage">修改</a>
                                                </li>
                                            </if>
                                            <if condition="check_auth('admin/Hpage/del')">
                                                <li data-id="{$vo['id']}" class="font-bold del-about"><a
                                                        href="javascript:;">删除</a></li>
                                            </if>
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<js href="/static/js/admin/jquery.min.js"/>
<js href="/static/js/admin/bootstrap.min.js"/>
<js href="/static/js/admin/content.min.js"/>
<js href="/static/js/admin/plugins/layui/layer/layer.js"/>
<script type="text/javascript" src="/static/js/admin/admincommon.js?v=20180820"></script>

<script>
    $(document).ready(function () {
        $(".ibox-content").on('click', '.edit-about', function () {
            var id = $(this).data("id");
            var status = $(this).data("status");
            $(location).attr('href', "{:url('admin/HPage/updateStatus')}?id=" + id + "&status=" + status);
        });

        $(".ibox-content").on('click', '.edit-hpage', function () {
            var id = $(this).data("id");
            $(location).attr('href', "{:url('admin/HPage/update')}?id=" + id);
        });


        $("#toggle_modal").on('click', function () {
            $(location).attr('href', "{:url('admin/HPage/add')}");
        });

        $(".ibox-content").on('click', '.del-about', function () {
            var about_id = $(this).data("id");
            layer.confirm("你确定要删除ID为【" + about_id + "】的图片吗？", {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("{:url('admin/HPage/del')}", {id: about_id}, function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {time: 500, icon: 1});
                        $("#about-" + about_id).remove();
                    } else {
                        layer.msg(data.msg, {time: 500, icon: 2});
                    }
                }, 'json');
            });
        });
    });

    function searchTitle(obj) {
        var keywords = $.trim($(obj).val());

        if (keywords.length <= 0) {
            window.location.replace(location.href);
        }
    }

</script>

</body>
</html>